package com.smx.util;

import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @ClassName DateFormatUtil
 * @Description TODO
 * @Author moses
 * @Date 2021/3/6
 **/
public class DateFormatUtil {
    private static SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public static String format(Date dateTime){
        return sdf.format(dateTime);
    }

    public static Date toTime(String formatString) {
        try {
            return sdf.parse(formatString);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return new Date();
    }
}
